<?php
/**
 * 异步客户端
 */
//use Swoole\Async\Client;

//$client = new Client(SWOOLE_SOCK_TCP);
$client = new Swoole\Client(SWOOLE_SOCK_TCP,SWOOLE_SOCK_ASYNC);


$client->on('connect',function ($client){
    $client->send('发送消息');
});
$client->on('receive',function ($client,$data){
        echo "接受消息：".$data."\n";
});
$client->on('close',function ($client){

});

if(!$client->connect('127.0.0.1',9501)){
    exit("链接失败. Error: {$client->errCode}\n");



}
//$client->send("hello\n");
//echo $client->recv();
//$client->close();